package com.nifostasky.comic.common.utils;

import com.nifostasky.comic.exceptions.BusinessException;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StringLocalUtil {

    public static List<Long> changeLongList(String ids){
        List<Long> collect = null;
        if (StringUtils.isBlank(ids)){
            throw new BusinessException("字符串不能为空");
        }
        try {
            collect = Arrays.asList(ids.split(",")).stream().map(i -> Long.valueOf(i.trim())).collect(Collectors.toList());
        }catch (Exception e){
            throw new BusinessException("字符串格式错误");
        }
        return collect;
    }
}
